package Composite.impl;

import Composite.service.Counter;

import java.util.ArrayList;
import java.util.List;

/**
 * @author chengjunjie
 * @date 2025-09-10
 */

public class Composite implements Counter {

    private List<Counter> counterList = new ArrayList<>();

    public void add(Counter counter) {
        counterList.add(counter);
    }

    @Override
    public int count() {
        int sum = 0;
        for (Counter counter : counterList) {
            sum += counter.count();
        }
        return sum;
    }
}
